package com.accp.hotevent.config;

import com.accp.hotevent.interceptor.AdminInterceptor;
import com.accp.hotevent.interceptor.LoginInterceptor;
import org.springframework.boot.autoconfigure.kafka.KafkaProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Resource
    LoginInterceptor loginInterceptor;

    @Resource
    AdminInterceptor adminInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/comment/add")
                .addPathPatterns("/event/add")
                .addPathPatterns("/user/avatar");

        registry.addInterceptor(adminInterceptor)
                .addPathPatterns("/admin/**");
    }
}
